import { getSession } from '@/auth/auth.service'
import { defineStore } from 'pinia'

export const authStore = defineStore('auth', {
  state: (): any => ({
      token: null,
      userinfo: null
  }),
  getters: {
    roleCode: (state) => state.userinfo?.roleCode
  },
  actions: {
    updateUserInfo() {
      const { token, userinfo } = getSession(['token','userinfo']);
      this.token = token
      this.userinfo = userinfo
    }
  }
})